package com.xgy.backend.controller;


import com.xgy.backend.common.ResultUtils;
import com.xgy.backend.dto.BoardKifuDto;
import com.xgy.backend.dto.ScreeningConditionDto;
import com.xgy.backend.service.Level0BoardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/board")
public class BoardController {
    @Autowired
    Level0BoardService level0BoardService;

    /**
     * 筛选指定盘面
     * @param screeningCondition    筛选条件
     * @return
     */
    @PostMapping ("/getScreeningResult")
    public Object getScreeningResult(@RequestBody ScreeningConditionDto screeningCondition){
        // 记录开始时间
        long startTime = System.nanoTime();

        List<BoardKifuDto> list = level0BoardService.getScreeningResult(screeningCondition);

        // 记录结束时间
        long endTime = System.nanoTime();
        // 计算执行时间差（以毫秒为单位）
        long executionTimeMillis = (endTime - startTime) / 1000000;

        System.out.println("异步分批次执行时间： " + executionTimeMillis + " 毫秒");
        return ResultUtils.success(list);
    }
}
